import 'rxjs/add/operator/filter';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/do';
import 'rxjs/add/operator/mergeMap';

import { Component, OnInit } from '@angular/core';
import { Router, NavigationEnd, ActivatedRoute } from '@angular/router';
import { Title } from '@angular/platform-browser';
import * as _ from 'lodash';

@Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
    styleUrls: ['./app.component.scss']
})

export class AppComponent implements OnInit {
    isShowNav: Boolean = false;  // 是否显示头部和菜单

    constructor(
        private titleService: Title,
        private router: Router
    ) { }

    ngOnInit() {
        this.router.events
            .filter(x => x instanceof NavigationEnd)
            .subscribe(x => {
                this.isShowNav = this.isShowByUrl(x as NavigationEnd);
            });
    }

    isShowByUrl(nav: NavigationEnd) {
        const urls = [
            'login'
        ];
        return !_.some(urls, x => {
            return nav.url.indexOf(x) >= 0;
        });
    }
}
